#!/bin/sh

# parameters: <repo-file-name> <user> <password>

# parameters

if [ $# -ne 3 ]; then
	echo "Usage: bash fossil-server-create-repo.sh <repo-file-name> <user> <password>"
	exit 1
fi

# create

strScriptRoot=$(dirname $(readlink -f "$0"))
cd "$strScriptRoot"
cd ../bin

FOSSIL_EXEC="./fossil"

"$FOSSIL_EXEC" new -A "$2" "$1"
if [ $? -ne 0 ]; then
	echo "Error: create failed"
	exit 2
fi

"$FOSSIL_EXEC" user password "$2" "$3" -R "$1"
"$FOSSIL_EXEC" setting autosync off -R "$1"
"$FOSSIL_EXEC" setting crnl-glob *, -R "$1"
"$FOSSIL_EXEC" setting encoding-glob *, -R "$1"
chmod ugoa+w "$1"

exit 0
